package com.ruoyi.wx.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wx.domain.AModule;
import com.ruoyi.wx.service.IAModuleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 拓展模块Controller
 * 
 * @author pan
 * @date 2022-12-09
 */
@RestController
@RequestMapping("/wx/module")
public class AModuleController extends BaseController
{
    @Autowired
    private IAModuleService aModuleService;

    /**
     * 查询拓展模块列表
     */
    @PreAuthorize("@ss.hasPermi('wx:module:list')")
    @GetMapping("/list")
    public TableDataInfo list(AModule aModule)
    {
        startPage();
        List<AModule> list = aModuleService.selectAModuleList(aModule);
        return getDataTable(list);
    }

    /**
     * 导出拓展模块列表
     */
    @PreAuthorize("@ss.hasPermi('wx:module:export')")
    @Log(title = "拓展模块", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AModule aModule)
    {
        List<AModule> list = aModuleService.selectAModuleList(aModule);
        ExcelUtil<AModule> util = new ExcelUtil<AModule>(AModule.class);
        util.exportExcel(response, list, "拓展模块数据");
    }

    /**
     * 获取拓展模块详细信息
     */
    @PreAuthorize("@ss.hasPermi('wx:module:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aModuleService.selectAModuleById(id));
    }

    /**
     * 新增拓展模块
     */
    @PreAuthorize("@ss.hasPermi('wx:module:add')")
    @Log(title = "拓展模块", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AModule aModule)
    {
        return toAjax(aModuleService.insertAModule(aModule));
    }

    /**
     * 修改拓展模块
     */
    @PreAuthorize("@ss.hasPermi('wx:module:edit')")
    @Log(title = "拓展模块", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AModule aModule)
    {
        return toAjax(aModuleService.updateAModule(aModule));
    }

    /**
     * 删除拓展模块
     */
    @PreAuthorize("@ss.hasPermi('wx:module:remove')")
    @Log(title = "拓展模块", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aModuleService.deleteAModuleByIds(ids));
    }
}
